﻿<%@ WebHandler Language="C#" Class="TypeEditName" %>

using System;
using System.Web;
using System.Data;
using System.Data.Common;
using System.Web.SessionState;

public class TypeEditName : IHttpHandler, IRequiresSessionState
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";

        /* 管理员信息验证 */
        if (!Admins.IsLogin(true))
            Utils.ShowEnd(context, -2);


        /* 外部数据处理 */
        int Id = Convert.ToInt32(context.Request.Params["Id"].ToString());
        int Item_Lang = Convert.ToInt32(context.Request.Params["Item_Lang"].ToString());
        int Typ = Convert.ToInt32(context.Request.Params["Typ"].ToString());
        string Type_Name = context.Request.Params["Type_Name"].ToString();

        /* 完整性验证 */
        if (Id < 0)
            Utils.ShowEnd(context, -1);
        if (Item_Lang < 1 || Item_Lang > 255)
            Utils.ShowEnd(context, -1);
        if (Typ < 1)
            Utils.ShowEnd(context, -1);
        if (Type_Name.Length < 1)
            Utils.ShowEnd(context, -1);

        /*执行*/
        DbParameter[] param = { 
            DBHelper.MakeInParam("@Id",(DbType)SqlDbType.SmallInt,2,Id),
            DBHelper.MakeInParam("@Type_Name",(DbType)SqlDbType.NVarChar,150,Type_Name),
            DBHelper.MakeInParam("@Item_Lang",(DbType)SqlDbType.TinyInt,1,Item_Lang),
            DBHelper.MakeInParam("@Typ",(DbType)SqlDbType.TinyInt,1,Typ)
        };

        Utils.ShowEnd(context, DBHelper.ExecuteScalar(CommandType.StoredProcedure, "Typ_Column_Add", param).ToString());

    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}